//log函数 多省8字符，方便自己加功能输出
const log = console.log.bind(console)
// const e = sel => document.querySelector(sel)
// const log = function (s) {
//     e('#id-text-log').value += '\n' +s
// }


const imageFromPath = function (path) {
    const img = new Image();
    img.src = path
    return img
}


const rectIntersects = function (a, b) {
    if (b.y > a.y && b.y < a.y + a.image.height) {
        if (b.x > a.x && b.x < a.x + a.image.width) {
            return true
        }
    }
    return false
}

const randomBetween = function (start, end) {
    let n = Math.random() * (end - start + 1)
    return Math.floor(n + start)
}

